| 1 | import { NextResponse, type NextRequest } from "next/server"; |
| 2 | import { getBillDiff } from "@/lib/feed"; |
| 3 | |
| 4 | export const dynamic = "force-dynamic"; |
| 5 | |
| 6 | export async function GET( |
| 7 | req: NextRequest, |
| 8 | { params }: { params: { id: string } } |
| 9 | ) { |
| 10 | const numeric = parseInt(params.id.replace(/^bill:/, ""), 10); |
| 11 | const sp = req.nextUrl.searchParams; |
| 12 | const from = sp.get("from") || "ih"; |
| 13 | const to = sp.get("to") || "rh"; |
| 14 | if (!Number.isFinite(numeric)) { |
| 15 | return NextResponse.json({ error: "not found" }, { status: 404 }); |
| 16 | } |
| 17 | const diff = getBillDiff(numeric, from, to); |
| 18 | if (!diff.changes.length) { |
| 19 | diff.note = |
| 20 | "No section-level diff on file. Some changes enter via voice vote or unanimous consent - no individual record exists for those."; |
| 21 | } |
| 22 | return NextResponse.json(diff); |
| 23 | } |